﻿// <copyright file="Name.cs" company="Microsoft Corporation">
// Copyright (c) 2009 Microsoft Corporation All Rights Reserved
// </copyright>
// <author>Michael S. Scherotter</author>
// <email>mischero@microsoft.com</email>
// <date>2009-03-25</date>
// <summary>OpenSocial Name wrapper</summary>

namespace opensocial
{
    using System.Windows.Browser;
    using Synergist;

    /// <summary>
    /// OpenSocial Name Wrapper class
    /// </summary>
    public class Name
    {
        /// <summary>
        /// Initializes a new instance of the Name class.
        /// </summary>
        /// <param name="scriptObject">the JavaScript opensocial.Name object</param>
        /// <remarks>This may not be present depending on user preferences.</remarks>
        public Name(ScriptObject scriptObject)
        {
            if (scriptObject == null)
            {
                return;
            }

            this.Unstructured = scriptObject.getField("opensocial.Name.Field.UNSTRUCTURED") as string;
            this.GivenName = scriptObject.getField("opensocial.Name.Field.GIVEN_NAME") as string;
            this.FamilyName = scriptObject.getField("opensocial.Name.Field.FAMILY_NAME") as string;
        }

        /// <summary>
        /// Gets or sets the unstructured name
        /// </summary>
        public string Unstructured { get; set; }

        /// <summary>
        /// Gets or sets the given name
        /// </summary>
        public string GivenName { get; set; }

        /// <summary>
        /// Gets or sets the family name
        /// </summary>
        public string FamilyName { get; set; }
    }
}
